/*
 * Access control methods (acm). Methods can have permission assigned to them 
 * and allow Roles to determine if access is allowed.
 * 
 * @author: Oren Zamir
 */
package org.valire.usermanagement.beans;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.valire.util.persistency.BaseEntity;


/**
 * The Class Roles.
 */
@Entity(name = "METHOD_ACCESS_CONTROL")
@Table(name = "METHOD_ACCESS_CONTROL")
public class MethodAccessControl extends BaseEntity{

	
	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1313629432725630643L;

	/** The method name. */
	@Column(name = "METHOD_NAME")
	private String methodName;
	
	/** The roles. */
	@ManyToMany( fetch = FetchType.EAGER)
	@JoinTable(name = "MAC_ROLES", joinColumns = { @JoinColumn(name = "MAC_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLES_ID") })
	private Set<Role> roles = new HashSet<Role>(0);


	/**
	 * Sets the method name.
	 *
	 * @param methodName the new method name
	 */
	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	/**
	 * Gets the method name.
	 *
	 * @return the method name
	 */
	public String getMethodName() {
		return methodName;
	}

	/**
	 * @param roles the roles to set
	 */
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	/**
	 * @return the roles
	 */
	public Set<Role> getRoles() {
		return roles;
	}

}
